'''
Created on Dec 8, 2015

@author: JimmyMo
'''
import unittest
from filter import Filter
import ruleprocessor
from fakecollector import FakeCollector

class TestFilter(unittest.TestCase):
    def test_filter_positive(self):
        collector = FakeCollector()
#         ruleprocessor = RuleProcessor("伴我同行")
        ruleProcessor = ruleprocessor.getRuleProcessor("RegexRuleProcessor", "伴我同行")
        mfilter = Filter(enabled=True, name="testfilter", collector=collector, ruleprocessor=ruleProcessor)
        is_match = mfilter.do_filter();
        self.assertTrue(is_match)
        
    def test_filter_negative(self):
        collector = FakeCollector()
#         ruleprocessor = RuleProcessor("伴我同行2")
        ruleProcessor = ruleprocessor.getRuleProcessor("RegexRuleProcessor", "伴我同行2")
        mfilter = Filter(enabled=True, name="testfilter", collector=collector, ruleprocessor=ruleProcessor)
        is_match = mfilter.do_filter();
        self.assertFalse(is_match)
        
if __name__ == "__main__":
    #import sys;sys.argv = ['', 'Test.testName']
    unittest.main()